home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4105 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  7.2 KB

  1. Path: news.cyberport.com!usenet
  2. From: tangent@cyberport.com (Warren Young)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: C vs Pascal
  5. Date: Sun, 28 Jan 1996 00:34:54 GMT
  6. Organization: ETR..., Inc.
  7. Message-ID: <310ab831.512924160@news.cyberport.com>
  8. References: <8B87053.0054014A15.uuout@swcbbs.com> <8B8F52F.0054014CDF.uuout@swcbbs.com> <4e0huu$rhn@classic.iinet.com.au>
  9. NNTP-Posting-Host: ppp1.cyberport.com
  10. X-Newsreader: Forte Agent .99c/16.141
  11.  
  12. ng@mitswa.com.au (John A Ng) wrote:
  13.  
  14. >In such as argument, we should really be objective and see why C is
  15. >actually more popular than it should.
  16. >
  17. >1.  C is portable.  Many people think C is portable in that it can be
  18. >taken from one platform and compile in another.  That is incorrect since
  19. >very very few programs written in C are fully portable except the
  20. >absurdly small.  
  21.  
  22. Of course, but that's not the point.  The point is that you can write
  23. a program in C whose core logic and routines are completely portable.
  24. Standard Pascal is more or less useless; so, to make it useful,
  25. Borland has greatly extended Turbo Pascal beyond the "standard"
  26. definition of Pascal.  But because none of these extensions have been
  27. standardized (except by fiat), TP code generally isn't portable.  On
  28. the other hand, C is a powerful language to start with, so portable
  29. programs can be written in it without straying from the standard
  30. language.
  31.  
  32. Now that C++ is more or less "here", we also have encapsulation as a
  33. portability tool.  It lets us hide platform-specific details behind a
  34. class interface.  Want to add another platform?  Add another class
  35. whose interface is the same as the others'.  You could do this in C,
  36. too, by placing "compatibility" functions in a single module, and
  37. writing a module for each platform you want to support.  Then, at
  38. compile time, compile the right module for the current platform, and
  39. link it in.
  40.  
  41. The C standard also defines standard methods for conditional
  42. compilation.  This lets you have a single section of source whose
  43. behavior changes depending on compile-time options, letting you change
  44. platforms by recompiling.  Most "portable" programs use this
  45. technique.
  46.  
  47. Sure, TP has many of these features, but none are portable.  You
  48. couldn't, for example, write TP code that would properly recompile on
  49. Pascal for the DEC Alpha based on compile-time options.
  50.  
  51. >for the learner because Turbo Pascal is lightning fast.  Many
  52. >professional programs are developed in Turbo Pascal!!!
  53.  
  54. As long as you only plan on supporting DOS and Windows, TP is a good
  55. choice.  
  56.  
  57. There _are_ hidden problems with this, though.  Your program may not
  58. need to be portable, but wouldn't it be nice if _others'_ programs
  59. were portable to _your_ platform?  Specifically, TP's nonportability
  60. means that it is open to fewer programmers, which means that there are
  61. fewer "freeware" modules floating around for you to use in your own
  62. code.  The TP world's crown jewel in this area is the SWAG collection.
  63. C/C++ has at least two: Snippets, and the alt.sources archives.  Plus,
  64. there are _many_ more independent libraries available.  Just take a
  65. look at the "libraries" FAQ posted to comp.lang.c++ periodically.
  66.  
  67. Then there's the commercial market: more user support means more
  68. vendor support, which means more third-party libraries.  Does TP have
  69. anything even close to the power of Rogue Wave's tools.h++?
  70.  
  71. So, portability influences a lot more than the number of platforms you
  72. can code for.
  73.  
  74. >2.  C is more efficient.  Bullshit.  C/C++ with all its standards is
  75. >absurdly inefficient in terms of development time.  C headers compiles
  76. >and compiles again for no apparent reason.  You must employ tricks to
  77. >prevent the recompile.  
  78.  
  79. This is a function of your environment, not the language itself.  We
  80. can talk "implementation" until the sun stops fusing, and we'll get
  81. nowhere.  If you need a faster recompile, get more MIPS or jump ship
  82. to a vendor whose compile times are lower.
  83.  
  84. However, it's clear that you don't really understand your environment.
  85. Headers don't "recompile for no apparent reason".  They recompile
  86. because something they depend on has changed.  If you don't want this
  87. sort of thing to happen, you have to reduce your header
  88. interdependencies.  Ask yourself, does this file _really_ need to
  89. include this header?  There are many legal and acceptable "tricks" to
  90. reduce this.  
  91.  
  92. You can't properly criticize something you don't understand.
  93.  
  94. >don't want to comment.  Turbo Pascal, on the other hand, is the most
  95. >efficient compiler on earth.  It makes any C compiler cry!!! -- A
  96. >staggering 20 to 1 ratio!!!  This is because there are no standards for
  97. >Turbo Pascal and Borland is free to optimize the languge and features as
  98. >it sees fit.
  99.  
  100. And when you're done, you get an executable that's either much bigger
  101. or much slower (I don't know which).  C compilers, on the other hand,
  102. spend more time optimizing, resulting in smaller, faster executables.
  103. _This_ is what we mean when we say "efficient".  End users don't give
  104. a darn how long it took to compile the program if the result is bigger
  105. or slower than a competing program written in a more "efficient"
  106. language.
  107.  
  108. >5.  C and Pascal are similar.  True, Turbo Pascal could properly be
  109. >called a dialect of C.  However, the latest reincarnation of Turbo
  110. >Pascal (called Delphi) includes many Smalltalk concepts.
  111. >
  112. >6.  C is always way ahead (better designed) than Pascal.  Incorrect.
  113. >C++ has incorporated things from Pascal like variable parameters (ie
  114. >passing by reference).  C++ also lacks proper string facility.
  115.  
  116. C++ did _not_ inherit pass-by-reference from Pascal.  Sure, Pascal had
  117. a similar mechanism first, but C has always had pointers, which is
  118. what the code compiles to anyway.  References are just syntactic sugar
  119. for pointers, and they were added to C++ to make operator overloading
  120. transparent.
  121.  
  122. Let's turn the tables, though, and see how many things TP swiped from
  123. C/C++:
  124.  
  125. o  Classes (or whatever TP with Objects calls them)
  126.  
  127. o  Free-form declarations -- standard Pascal requires that your
  128. declarations be segregated by type, with only one type group at each
  129. level of scope.
  130.  
  131. o  Bitwise operators
  132.  
  133. o  Separate compilation (UNITs and modules)
  134.  
  135. o  Conditional compilation
  136.  
  137. What has C/C++ still got that TP doesn't?
  138.  
  139. o  Multiple inheritance
  140.  
  141. o  Variable-length argument lists
  142.  
  143. o  Forward references and prototypes.  Functions don't have to be in a
  144. specific order in C/C++.
  145.  
  146. o  A more powerful base language -- Try writing writeln() in Pascal
  147. sometime.  You can't do it because the language doesn't support vararg
  148. functions, so the language had to have that function defined into it.
  149. Same goes for ord() and more.  None of the functions in the C/C++
  150. standard are built into the language, because they don't have to be.
  151.  
  152. o  Pointer arithmetic -- try writing strcpy() in Pascal.  Or anything
  153. else that manipulates blocks of memory.  Related to this is that,
  154. because the size of an array is a part of its type, you can't have
  155. general-purpose memory-block manipulation routines.
  156.  
  157. And to be fair, there is at least one thing Pascal has that C/C++
  158. doesn't: nested procedures.  Whoop!
  159.  
  160. >(PS:  I am a profession C++ programmer who started with Turbo Pascal).
  161.  
  162. I am a professional C++ programmer who started with ISO Pascal, and
  163. have had many similar discussions with your fellow TPers.  I remain
  164. unconvinced.
  165.  
  166. = Warren --
  167.